/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author joao
 */
@Entity
@Table(name = "proposta_etapa_perc", catalog = "salao", schema = "public")
@NamedQueries({
    @NamedQuery(name = "PropostaEtapaPerc.findAll", query = "SELECT p FROM PropostaEtapaPerc p")})
public class PropostaEtapaPerc implements Comparable<PropostaEtapaPerc>, Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "proposta_etapa_perc_id_etapa_perc_seq")
    @SequenceGenerator(name = "proposta_etapa_perc_id_etapa_perc_seq", sequenceName = "proposta_etapa_perc_id_etapa_perc_seq", initialValue = 1, allocationSize = 1)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_etapa_perc", nullable = false)
    private Integer idEtapaPerc;
    @Size(max = 200)
    @Column(name = "dsc_perc", length = 200)
    private String dscPerc;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "perc_etapa", precision = 10, scale = 2)
    private BigDecimal percEtapa;
    @Column(name = "num_ordem")
    private Integer numOrdem;
    @JoinColumn(name = "id_etapa_desc", referencedColumnName = "id_etapa_desc", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private PropostaEtapaDesc idEtapaDesc;

    public PropostaEtapaPerc() {
    }

    public PropostaEtapaPerc(Integer idEtapaPerc) {
        this.idEtapaPerc = idEtapaPerc;
    }

    public Integer getIdEtapaPerc() {
        return idEtapaPerc;
    }

    public void setIdEtapaPerc(Integer idEtapaPerc) {
        this.idEtapaPerc = idEtapaPerc;
    }

    public String getDscPerc() {
        return dscPerc;
    }

    public void setDscPerc(String dscPerc) {
        this.dscPerc = dscPerc;
    }

    public BigDecimal getPercEtapa() {
        return percEtapa;
    }

    public void setPercEtapa(BigDecimal percEtapa) {
        this.percEtapa = percEtapa;
    }

    public PropostaEtapaDesc getIdEtapaDesc() {
        return idEtapaDesc;
    }

    public void setIdEtapaDesc(PropostaEtapaDesc idEtapaDesc) {
        this.idEtapaDesc = idEtapaDesc;
    }

    public Integer getNumOrdem() {
        return numOrdem;
    }

    public void setNumOrdem(Integer numOrdem) {
        this.numOrdem = numOrdem;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEtapaPerc != null ? idEtapaPerc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PropostaEtapaPerc)) {
            return false;
        }
        PropostaEtapaPerc other = (PropostaEtapaPerc) object;
        return !((this.idEtapaPerc == null && other.idEtapaPerc != null) || (this.idEtapaPerc != null && !this.idEtapaPerc.equals(other.idEtapaPerc)));
    }

    @Override
    public String toString() {
        return "br.jm.financeiro.entity.PropostaEtapaPerc[ idEtapaPerc=" + idEtapaPerc + " ]";
    }

    @Override
    public int compareTo(PropostaEtapaPerc o) {
        int valor = numOrdem.compareTo(o.numOrdem);
        return (valor != 0 ? valor : 1);
    }
    
}
